package com.iacrqq.sedaf.config;

import java.util.HashMap;
import java.util.Map;

public class MemoryConfiguration implements Configuration
{
	Map<String, Object> store = new HashMap<String, Object>();
	
	@Override
	public void set(String key, Object value)
	{
		store.put(key, value);
	}
	
	@Override
	public int getInt(String key)
	{
		String strValue = (String)store.get(key);
		return Integer.valueOf(strValue.trim());
	}

	@Override
	public int getInt(String key, int defaultValue)
	{
		String strValue = (String)store.get(key);
		if(strValue == null)
		{
			return defaultValue;
		}
		
		return Integer.valueOf(strValue.trim());
	}
	
	@Override
	public String getString(String key)
	{
		return (String)store.get(key);
	}

	@Override
	public String getString(String key, String defaultValue)
	{
		String value = (String)store.get(key);
		
		if(value == null)
		{
			return defaultValue;
		}
		
		return value;
	}

}
